home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earkit / mail / thor / thorftp.lha / thorftp / ThorFTP.br next >
Text File  |  1996-06-17  |  4KB  |  123 lines

  1. /* ThorFTP.br V1.1 © 1996 Roy Brown
  2.    $ver: ThorFTP.br V1.1 (17.6.96)
  3.  
  4.    ThorFTP will take Thor Download Events and turn them into an EMail Event.
  5.    It will address this new Event to the configured FTP Mail server.
  6.  
  7.    It can be run either from within Thor (when leaving a system perhaps), or from a shell
  8.    (or DOpus button). Thor does not need to be running.
  9.  
  10.    It has been tested with src.doc.ic.ac.uk (The main UK Aminet mirror) and
  11.    ftp.uni-paderborn.de (Paderborn University in Germany).
  12.    Commands for other FTP Mail servers may differ. */
  13.  
  14. /* Variables - set these to match your system */
  15. SystemName ='Internet'                          /* The name of your mail/news system in Thor.  */
  16. EMailConf  ='EMail'                             /* Your EMail conference.                      */
  17. ToWhom     ='FTP Mail'                          /* For the 'To' line. Can be anything you like */
  18. ToWhere    ='ftpmail@doc.ic.ac.uk'              /* FTP mail server address.                    */
  19.                                                 /* For the UK use 'ftpmail@doc.ic.ac.uk'.      */
  20.                                                 /* For Germany use 'ftp-mail@uni-paderborn.de'.*/
  21. Subjeck ='FTP by Email'                         /* For the 'Subject' line. Anything you like.  */
  22.  
  23.  
  24. /*** There should be no reason to alter anything below here, although Kev Cowans probably will ;) ***/
  25.  
  26. Options results
  27. Options failat 21
  28.  
  29. /* The variables below set the commands used in the script sent to the FTPmail server.
  30.     These differ slightly from server to server. */
  31.  
  32. Aminetpath ='pub/aminet/'     /* The Aminet directory */
  33.  
  34. If ToWhere='ftpmail@doc.ic.ac.uk' Then
  35.    Do
  36.       Start='open'
  37.       Code ='mime'
  38.    End
  39.  
  40. If ToWhere='ftp-mail@uni-paderborn.de' Then
  41.    Do
  42.       Start='begin'
  43.       Code ='uuencode'
  44.    End
  45.  
  46. /* Check for BBSRead port. Open if necessary */
  47. If ~Show('P','BBSREAD') Then
  48.    Do
  49.       Address Command
  50.       "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  51.       'WaitForPort BBSREAD'
  52.    End
  53.  
  54. HW=0           /* Text file not open */
  55.  
  56. /* Get number of Events waiting to be sent */
  57.  
  58. EDF_ACTIVE      = '00000000'x   /* Event is active  */
  59.  
  60. EVE_ENTERMSG    = 0             /* Enter message     */
  61. EVE_DOWNLOAD    = 4             /* Download File     */
  62.  
  63. Address BBSREAD
  64.  
  65. GETBBSDATA SystemName stem BBSDATA
  66.  
  67. If BBSDATA.NUMEVENTS ~= 0 Then
  68.    Do num=BBSDATA.FIRSTEVENT To BBSDATA.LASTEVENT
  69.       READBREVENT systemname EVENTNR num TAGSSTEM eventtag DATASTEM eventdata
  70.       If EVENTDATA.FLAGS=EDF_ACTIVE Then
  71.          If EVENTDATA.EVENTTYPE~=EVE_DOWNLOAD Then
  72.             Iterate num
  73.          Else
  74.             Do
  75.                RemoteFile='get 'AminetPath||EVENTTAG.DIRECTORY||'/'||EVENTTAG.FILENAME
  76.                Call WriteText
  77.                UPDATEBREVENT BBSNAME systemname EVENTNR num SETDONE
  78.                Iterate num
  79.             End
  80.    End
  81. Else
  82.    Exit
  83.  
  84. /* If all Download Events processed, complete text file and close it */
  85. If HW ~=0 Then
  86.    Do
  87.       String=WriteLn(FTP,'quit')
  88.       Closed=Close(FTP)
  89.       Call EventWrite
  90.    End
  91. Address Command 'Delete >NIL: T:ThorFTP.txt'
  92. Exit
  93.  
  94. /* Write the text file for the Email */
  95. WriteText:
  96.    If HW=0 Then
  97.       Do
  98.          a=Open(FTP,"T:ThorFTP.txt",w)   /* Open text file */
  99.          String=WriteLn(FTP,Start)
  100.          HW=1
  101.       End
  102.    String=WriteLn(FTP,Code)
  103.    String=WriteLn(FTP,RemoteFile)
  104. Return
  105.  
  106. /* Write the new EMail Event */
  107. EventWrite:
  108.    Address BBSREAD
  109.  
  110.    EVE_ENTERMSG    = 0       /* 'Enter' message type */
  111.  
  112.    Drop BBSDATA.
  113.  
  114.    UNIQUEMSGFILE bbsname SystemName stem Text FROMFILE 'T:ThorFTP.txt'
  115.  
  116.    BBSDATA.TONAME  = ToWhom
  117.    BBSDATA.TOADDR  = ToWhere
  118.    BBSDATA.SUBJECT = Subjeck
  119.    BBSDATA.CONFERENCE = EMailConf
  120.    BBSDATA.MSGFILE = Text.FILEPART
  121.    WRITEBREVENT bbsname SystemName event EVE_ENTERMSG stem BBSDATA
  122. Return
  123.